<% content_for :after_javascript_libraries do %>
  <%= javascript_include_tag 'https://www.google.com/jsapi' %>
  <%= javascript_include_tag 'refinerycms-stat' %>
  <%= javascript_include_tag 'refinerycms-stat-translate' %>
<% end %>

<div id="login" style="visibility:hidden;">
  <form action='#'>
    <span id='status'><%= t('.login_analytics_html', :analytics_page_code => RefinerySetting.find_or_set(:analytics_page_code, "UA-0000000-0")) %></span>
    <br/>
    <input id='buttonLogin' type='button' value='<%= t(".button_login_text") %>'/>
</form>
</div>
<div id="logged" style="visibility:hidden;">
  <%= t('.link_analytics_html') %>
  <div id="tabs">
    <ul>
      <li><a href="#tabs-1"><%= t('.title_page_views') %></a></li>
      <li><a href="#tabs-2"><%= t('.title_visits') %></a></li>
      <li><a href="#tabs-3"><%= t('.title_visitors') %></a></li>
      <li><a href="#tabs-4"><%= t('.title_average_time') %></a></li>
      <li><a href="#tabs-5"><%= t('.title_source') %></a></li>
      <li><a href="#tabs-6"><%= t('.title_keywords') %></a></li>
    </ul>
    <div id="page_part_editors">
      <div id="tabs-1" class="stat">
      <div id='pageViewsTableDiv'></div>
      <div id='pageViewsColumnChartDiv' style="display:inline"></div>
      <div id='pageViewsChartDiv' style="display:inline"></div>
    </div>
    <div id="tabs-2" class="stat"> 
      <table>
        <tr>
          <td><div id='visitsTableDiv' style="display:inline"></div></td>
          <td><div id='visitsLineChartDiv' style="display:inline"></div></td>
        </tr>
      </table>
    </div>
    <div id="tabs-3" class="stat">
      <table>
        <tr>
          <td><div id='visitorsTableDiv' style="display:inline"></div></td>
          <td><div id='visitorsLineChartDiv' style="display:inline"></div></td>
        </tr>
      </table>
    </div>
    <div id="tabs-4" class="stat">
      <table>
        <tr>
          <td><div id='timesOnSiteTableDiv' style="display:inline"></div></td>
          <td><div id='timesOnSiteLineChartDiv' style="display:inline"></div></td>
        </tr>
      </table>
    </div>
    <div id="tabs-5" class="stat">
      <table>
        <tr>
          <td><div id='sourceTableDiv' style="display:inline"></div></td>
          <td><div id='sourcePieChartDiv' style="display:inline"></div></td>
        </tr>
      </table>
    </div>
    <div id="tabs-6" class="stat">
      <table>
        <tr>
          <td><div id='keywordTableDiv' style="display:inline"></div></td>
          <td><div id='keywordPieChartDiv' style="display:inline"></div></td>
        </tr>
      </table>
    </div>
  </div>
  <!-- For the API to work in IE, an image must be requested from the same
       domain the script is hosted on. The image doesn't actually have
       to exist, just be requested. More info here :
       http://code.google.com/apis/gdata/client-js.html
      -->
  <img style='visibility:hidden' src='__utm.gif' alt='required for GData'/>
</div>

<% content_for :javascripts do %>
  <script>
    $(document).ready(function(){
      $(function() {
        $( "#tabs" ).tabs();
      });			
      collectStatsData('<%= RefinerySetting.find_or_set(:analytics_page_code, "UA-0000000-0") %>');
    });
  </script>
<% end %>

<% content_for :stylesheets do %>
  <%= stylesheet_link_tag 'stat' %>
<% end %>
